@extends('admin.layout.layout')
@section('content')
  	<div class="row">
       <div class="col-lg-12">
            <h1 class="page-header">用户列表</h1>
       </div>
    </div>
     <div class="col-lg-12"> 
   <div class="panel panel-default"> 
    <div class="panel-heading">
      DataTables Advanced Tables 
    </div> 
    <!-- /.panel-heading --> 
    <div class="panel-body"> 
     <div class="dataTable_wrapper"> 
      <div class="dataTables_wrapper form-inline dt-bootstrap no-footer" id="dataTables-example_wrapper">
        
      <form action="{{url('/admin/user/list')}}" method="get">
       <div class="row">
        <div class="col-sm-6">
         <div id="dataTables-example_length" class="dataTables_length">
          <label>显示 <select class="form-control input-sm" aria-controls="dataTables-example" name="num">
          <option value="2">2</option>
        
          </select> 条</label>
         </div>
        </div>
        <div class="col-sm-6">
         <div class="dataTables_filter" id="dataTables-example_filter">
          <label>用户名:<input name="keywords" class="form-control input-sm" type="search" />
          </label>
          <button class="btn btn-info">查询</button>
         </div>
        </div>
       </div>
      </form>

       <div class="row">
        <div class="col-sm-12">
         <table aria-describedby="dataTables-example_info" role="grid" class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example"> 
          <thead> 
           <tr role="row">
            <th aria-label="Rendering engine: activate to sort column descending" colspan="1" rowspan="1" aria-controls="dataTables-example" tabindex="0" class="sorting_asc">ID</th>
            <th aria-label="Browser: activate to sort column ascending" style="width: 199px;" colspan="1" rowspan="1" aria-controls="dataTables-example" tabindex="0" class="sorting">用户名</th>
            <th aria-label="Platform(s): activate to sort column ascending" style="width: 180px;" colspan="1" rowspan="1" aria-controls="dataTables-example" tabindex="0" class="sorting">email</th>
            <th aria-label="Engine version: activate to sort column ascending" style="width: 153px;" colspan="1" rowspan="1" aria-controls="dataTables-example" tabindex="0" class="sorting">电话</th>
            <th aria-label="CSS grade: activate to sort column ascending" style="width: 111px;" colspan="1" rowspan="1" aria-controls="dataTables-example" tabindex="0" class="sorting">头像</th>
            <th aria-label="CSS grade: activate to sort column ascending" style="width: 111px;" colspan="1" rowspan="1" aria-controls="dataTables-example" tabindex="0" class="sorting">昵称</th>
            <th aria-label="CSS grade: activate to sort column ascending" style="width: 111px;" colspan="1" rowspan="1" aria-controls="dataTables-example" tabindex="0" class="sorting">权限</th>
             <th aria-label="CSS grade: activate to sort column ascending" style="width: 111px;" colspan="1" rowspan="1" aria-controls="dataTables-example" tabindex="0" class="sorting">操作</th>

           </tr>
          </thead> 
          <tbody> 
          @foreach($user as $k=>$v)
           <tr role="row" class="gradeA odd"> 
            <td class="sorting_1 sid">{{$v->id}}</td> 
            <td>{{$v->username}}</td> 
            <td class="center">{{$v->email}}</td> 
            <td class="center">{{$v->phone}}</td> 
            <td class="center"><img src="{{$v->pic}}" width="50"/></td> 

            <td class="center">{{$v->nc}}</td> 
            <td class="center">{{$xq[$v->qx]}}</td>
            <td class="center">
            <a class="fa fa-trash-o delete">删除</a>
            |
            <a href="{{url('/admin/user/edit',['id'=>$v->id])}}" class="fa fa-wrench">修改</a>
            </td> 
           </tr>
           @endforeach

          </tbody> 
         </table>
        </div>
       </div>
       <div class="row">
        
        <div class="col-sm-6">
         <div id="dataTables-example_paginate" class="dataTables_paginate paging_simple_numbers">
          {!! $user->appends($request)->render() !!}
         </div>
        </div>
       </div>
      </div> 
     </div> 
     <!-- /.table-responsive --> 
    </div> 
    <!-- /.panel-body --> 
   </div> 
   <!-- /.panel --> 
  </div> 
  <!-- /.col-lg-12 --> 
 @endsection
  @section('myjs')
    <script type="text/javascript">
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
       $('.delete').click(function(){
            
           var id = $(this).parents('tr').find('.sid').html();
           var dd = $(this);
           //发送ajax
            $.post('/admin/user/delete',{id:id},function(data){

              if(data == 1 ){
                 dd.parents('tr').remove();
              }else{
                alert('失败');
              }
            })
           return  false;
       })

       
    </script>
  @endsection